package softwareinlife.android.ux.option;

import softwareinlife.android.ux.R;
import softwareinlife.android.ux.R.color;
import softwareinlife.android.ux.R.layout;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;

public class OptionSelect3Activity extends Activity {
	// public Float x1;
	// public Float y1;

	private OnCheckedChangeListener m_BasicCheckListener;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.optionselect2);

		SharedPreferences pref = getSharedPreferences("pref",
				Activity.MODE_PRIVATE);

		// CheckBox check1 = (CheckBox)findViewById(R.id.CheckBox01);
		// CheckBox check2 = (CheckBox)findViewById(R.id.CheckBox02);
		final Boolean chk1 = pref.getBoolean("check1", false);
		final Boolean chk2 = pref.getBoolean("check2", false);

		// check1.setChecked(chk1);
		// check2.setChecked(chk2);

		/*
		 * CheckBox[] setOfCheckBoxes = new CheckBox[]
		 * {(CheckBox)findViewById(R.id.CheckBox01),
		 * (CheckBox)findViewById(R.id.CheckBox02), };
		 */
		m_BasicCheckListener = new OnCheckedChangeListener() {
			public void onCheckedChanged(CompoundButton buttonView,
					boolean isChecked) {
				// int i = 0;
				// int j = 0;
				// System.out.println("false");

				if (isChecked) {
					// i = R.id.CheckBox01;
					// j = R.id.CheckBox02;
					/*
					 * if(chk1) { try{ Intent k = new Intent(OptionSelect2.this,
					 * OptionSelect.class); startActivity(k);
					 * System.out.println("stand"); }catch(Exception e){}
					 * 
					 * 
					 * buttonView.setBackgroundResource(R.color.highlightedColor)
					 * ; }
					 */
					if (chk2) {
						try {
							finish();
							System.out.println("server");
						} catch (Exception e) {
						}
						// i = 0;
						buttonView
								.setBackgroundResource(R.color.highlightedColor);
					}

				}
			}
		};
		// check1.setOnCheckedChangeListener(m_BasicCheckListener);
		// check2.setOnCheckedChangeListener(m_BasicCheckListener);

		/*
		 * for(int i = 0; i < setOfCheckBoxes.length; i++){
		 * setOfCheckBoxes[i].setOnCheckedChangeListener(m_BasicCheckListener);
		 * }
		 */
	}

	public void onStop() {
		super.onStop();
		SharedPreferences pref = getSharedPreferences("pref",
				Activity.MODE_PRIVATE);
		SharedPreferences.Editor editor = pref.edit();
		// CheckBox check1 = (CheckBox)findViewById(R.id.CheckBox01);
		// CheckBox check2 = (CheckBox)findViewById(R.id.CheckBox02);

		// editor.putBoolean("check1", check1.isChecked());
		// editor.putBoolean("check2", check2.isChecked());

		editor.commit(); // ��옣�⑸땲��
	}

	/*
	 * @Override public boolean onTouchEvent(MotionEvent event) { switch
	 * (event.getAction()) { case MotionEvent.ACTION_DOWN:
	 * 
	 * x1 = event.getX();
	 * 
	 * y1 = event.getY();
	 * 
	 * try{ System.out.println("x : " + x1.toString());
	 * System.out.println("y : " + y1.toString());
	 * 
	 * }catch(Exception e){}
	 * 
	 * if(x1 >= 132 && x1 <= 175 && y1 >= 361 && y1 <= 405) {
	 * 
	 * //Intent i = new Intent(this, Checkbox1.class);
	 * 
	 * //startActivity(i);
	 * 
	 * 
	 * //openDialog(); }
	 * 
	 * break; }
	 * 
	 * return true;
	 * 
	 * }
	 * 
	 * @Override public boolean onTouch(View v, MotionEvent event) { // TODO
	 * Auto-generated method stub return false;}
	 */
	/*
	 * @Override public void onCheckedChanged(CompoundButton buttonView, boolean
	 * isChecked) { // TODO Auto-generated method stub if(isChecked){
	 * //buttonView.setBackgroundResource(R.color.highlightedColor); Intent i =
	 * new Intent(this, Checkbox1.class);
	 * 
	 * startActivity(i);
	 * 
	 * } else {
	 * //buttonView.setBackgroundColor(android.R.drawable.screen_background_dark
	 * ); }
	 * 
	 * 
	 * 
	 * }
	 */

}